class Solution:
    def findMaxAverage(self, nums, k):
        max_sum = sum(nums[:k])
        window_sum = max_sum
        for i in range(k, len(nums)):
            window_sum = window_sum - nums[i-k] + nums[i]
            max_sum = max(window_sum, max_sum)
        return max_sum / k
if __name__ == '__main__':
    nums = [1,12,-5,-6,50,3]
    k = 4
    print(Solution().findMaxAverage(nums, k))